package cn.sptpc.servlet;

import cn.sptpc.service.UserService;
import cn.sptpc.service.impl.UserServiceI;

import javax.servlet.ServletException;
import javax.servlet.annotation.WebServlet;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import java.io.IOException;

@WebServlet("/queryUser.do")
public class QueryAllServlet extends HttpServlet {
    protected void doPost(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
        response.setContentType("text/json;charset=utf8");
        UserService service = new UserServiceI();
        if("queryUser".equals(request.getParameter("transaction"))){
            response.getWriter().print(service.queryUser(request));
        }else {
            String allUser = service.getAllUser(request);
            response.getWriter().print(allUser);
        }
    }

    protected void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {

    }
}
